﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameServer.Managers
{
    struct RankPermissions
    {
        public String[] Permissions;
        public RankPermissions(int Rank)
        {
            Permissions = DB.runReadColumn("SELECT permission FROM rank_permissions WHERE minrank <=" + Rank.ToString(), 0);
        }
    }

    class RankManager
    {
        private static RankPermissions[] _RankPerm;

        public static void load()
        {
            try
            {
                Log.WriteLine("Loading the permisions for each rank..");
                _RankPerm = new RankPermissions[7];
                for (int I = 0; I <= 6; I++)
                {
                    _RankPerm[I] = new RankPermissions(I);
                }

                Log.WriteLine("Permisions loaded for all ranks!");
            }
            catch { }
        }

        public static bool HasPermision(int Rank, string Permision)
        {
            return _RankPerm[Rank].Permissions.Contains<string>(Permision);
        }
    }
}
